//package br.sed.theenemy.model.dao;
//
//import java.sql.ResultSet;
//import java.sql.SQLException;
//import java.text.DateFormat;
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.util.ArrayList;
//import java.util.List;
//
//import br.sed.theenemy.business.exception.InvalidUniqueBeanException;
//import br.sed.theenemy.model.bean.Action;
//import br.sed.theenemy.model.bean.ActionType;
//import br.sed.theenemy.model.bean.Contact;
//import br.sed.theenemy.model.bean.User;
//import br.sed.theenemy.presentation.EnemyConstants;
//
///**
// * 
// * @author JulioCB
// * @email jcbjulio@gmail.com
// * 
// */
//public class ActionTypeDao extends AbstractDao{
//	
//	private static DateFormat DATE_FORMAT_DB = new SimpleDateFormat(EnemyConstants.SIMPLE_DATE_FORMAT_DB);
//	
//	// Unica instancia da classe
//	protected static ActionTypeDao instanceDao;
//	
//	public void create(ActionType actionType){
//		String sql = "insert into actions (id_action, description) values " +
//						 "("+getId()+"," +
//						 "'"+actionType.getDescription()+"')";			
//		//System.out.println("Log:"+sql);
//		executeQuery(sql, "Error: Insert ActionType");
//	}
//	
//	public ActionType findActionTypeById(Long id) throws SQLException, ParseException, NumberFormatException, InvalidUniqueBeanException{
//		String sql = "select * from action_types a " +
//						"where a.id_action = "+ id;
//		ResultSet result = null;
//		result = getRS(sql);
//		
//		ActionType actionType = getActionType(result);
//		return actionType;
//	}
//		
//	private List<ActionType> fillActionTypeList(ResultSet result) throws NumberFormatException, SQLException, ParseException{
//		List<ActionType> actionList = new ArrayList<ActionType>();
//		while(result.next()){
//			ActionType actionType = new ActionType();
//			actionType.setId(Long.parseLong(result.getString("id_action")));
//			actionType.setDescription(result.getString("description"));
//			actionList.add(actionType);
//		}
//		return actionList;
//	}
//	
//	private ActionType getActionType(ResultSet result) throws InvalidUniqueBeanException, NumberFormatException, SQLException, ParseException{
//		List<ActionType> actionTypeList = fillActionTypeList(result);
//		if(actionTypeList.size()==1){
//			return actionTypeList.get(0);	
//		}else{
//			throw new InvalidUniqueBeanException("Error getting ActionType, not unique");
//		}
//	}
//	
//	public static ActionTypeDao getInstance(){
//		
//		// Verifica se ja tem instancia
//		if ( instanceDao == null ){			
//			instanceDao = new ActionTypeDao();			
//		}
//		
//		return instanceDao;
//		
//	}
//}
